import requests
'''方法一：登陆网页 '''
play = {'username':'m','password':'password'}
r = requests.post('https://pythonscraping.com/pages/cookies/welcome.php',data=play)  # 登陆网站
# print(r.cookies.get_dict())  # 这个是用户名
r2 = requests.get('https://pythonscraping.com/pages/cookies/profile.php',cookies=r.cookies) # 登陆网站二
# print(r2.text)  # 获取网站信息

'''方法二：登陆网页'''
sess = requests.Session()
play2 = {'username':'m','password':'password'}
r3 = sess.post('https://pythonscraping.com/pages/cookies/welcome.php',data=play2)
print(r3.cookies.get_dict())
r4 = sess.get('https://pythonscraping.com/pages/cookies/profile.php')
print(r4.text)